/**
 * <p>Title: Places.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2013-7-24 上午05:11:44  张志芳  Create
 *</pre>
 */
package com.baosight.sczx.common.zm.cInterface.cb;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;

/**
 * <p>Title: Places.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2013-7-24 上午05:11:44  张志芳  Create
 *</pre>
 */
public class Places {
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	/**
	 * 构造采面和巷道block
	 * <p>Function: getPlacesBlock</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-8-8上午08:44:11 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked"})
	public static EiBlock getPlacesBlock(String blockName, Boolean isPlan)
	{
		if("".equals(blockName) || blockName == null)
		{
			blockName="cmes.cb.places";
		}
		EiBlock block = new EiBlock(blockName);

		
		EiColumn eiColumn = new EiColumn("fdPlaceId");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdPlace");
		eiColumn.setType("C");
		block.addMeta(eiColumn);	
		
		eiColumn = new EiColumn("fdPlaceType");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdUnit");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdSurplus");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdSurplusLength");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdHeight");
		eiColumn.setType("c");
		eiColumn.setDescName("采高");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdBulk");
		eiColumn.setType("c");
		eiColumn.setDescName("容重");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdWidth");
		eiColumn.setType("c");
		eiColumn.setDescName("宽度");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdChance");
		eiColumn.setType("c");
		eiColumn.setDescName("回采率");
		block.addMeta(eiColumn);
		
		Map map = new HashMap();
		if(isPlan)
		{		
			map.put("fdStatusPlan", "1");
		}
		
		List<Map>  list = dao.query("ZMCBWorkingface.queryForGT", map);//采面
		list.addAll(dao.query("ZMCBRoadway.queryForGT", map));//巷道
		
		block.addRows(list);
		return block;
	}
	
	/**
	 * 获取采面block
	 * <p>Function: getWorkfaceBlock</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-7-24上午09:12:45 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked"})
	public static EiBlock getWorkfaceBlock(String blockName, Boolean isPlan)
	{
		if("".equals(blockName) || blockName == null)
		{
			blockName="cmes.cb.workface";
		}
		EiBlock block = new EiBlock(blockName);

		
		EiColumn eiColumn = new EiColumn("fdPlaceId");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdPlace");
		eiColumn.setType("C");
		block.addMeta(eiColumn);	
		
		eiColumn = new EiColumn("fdSurplus");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		Map map = new HashMap();
		if(isPlan)
		{		
			map.put("fdStatusPlan", "1");
		}
		
		List<Map>  list = dao.query("ZMCBWorkingface.queryForGT", map);//采面
		
		block.addRows(list);
		return block;
	}

	/**
	 * 获取巷道Block
	 * <p>Function: getRoadwayBlock</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-7-24上午09:14:09 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked"})
	public static EiBlock getRoadwayBlock(String blockName, Boolean isPlan)
	{
		if("".equals(blockName) || blockName == null)
		{
			blockName="cmes.cb.roadway";
		}
		EiBlock block = new EiBlock(blockName);

		
		EiColumn eiColumn = new EiColumn("fdPlaceId");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdPlace");
		eiColumn.setType("C");
		block.addMeta(eiColumn);	
		
		eiColumn = new EiColumn("fdSurplus");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		Map map = new HashMap();
		if(isPlan)
		{		
			map.put("fdStatusPlan", "1");
		}
		
		List<Map>  list = dao.query("ZMCBRoadway.queryForGT", map);//巷道
		
		block.addRows(list);
		return block;
	}
}
